<script setup>
import { onMounted, ref } from 'vue'
import * as echarts from 'echarts'

const charts = ref()
onMounted(() => {
//一个容器可以展示多种类型的图形图标
  const mychart = echarts.init(charts.value);
  mychart.setOption({
    title: {
      text: '景区排行',
      link: 'https://cn.bing.com/images/search?q=%e8%b5%9b%e9%87%8c%e6%9c%a8%e6%b9%96%e6%99%af%e5%8c%ba%e5%ae%98%e7%bd%91&qpvt=%e8%b5%9b%e9%87%8c%e6%9c%a8%e6%b9%96%e6%99%af%e5%8c%ba%e5%ae%98%e7%bd%91&form=IGRE&first=1',
      left: 'center',
      textStyle: {
        color: '#24bfee',
        fontSize: 22,
      },
      subtext: "各大景区排行热度",
      subtextStyle: {
        color: '#24bfee',
        fontSize: 16,
      }
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross'
      },
      backgroundColor: 'rgba(245, 0.8)',
      padding: [5, 10],
      textStyle: {
        color: '#fff',
        fontSize: 14
      }
    },
    toolbox: {
      feature: {
        dataView: {show: true, readOnly: false},
        magicType: {show: true, type: ['line', 'bar']},
        restore: {show: true},
        saveAsImage: {show: true}
      }
    },
    xAxis: {
      type: 'category',
      data: ['雪山', '峡谷', '九龙', '云顶', '九寨沟', '都江堰', '橘子洲头'],
      axisTick: {
        alignWithLabel: true
      }
    },
    yAxis: {type: 'value'},
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true
    },
    series: [
      {
        name: '景区热度',
        type: 'bar',
        data: [1000, 900, 800, 700, 600, 500, 400, 300, 200],
        label: {show: true, position: 'top'},
        showBackground: true,
        backgroundStyle: {
          color: 'rgba(128, 0.1, 0.2, 0.1)'
        },
        itemStyle: {
          borderRadius: [10, 10, 0, 0],
          color: function (data) {
            const arr = ['#f56c6c', '#e6a23c', '#1aee92', '#1fb9f6', '#5c7cb8', '#d4b9da', '#f3a43b'],
                index = data.dataIndex;
            return arr[index];
          }
        }
      },
      {
        type: 'line',
        data: [600, 900, 1000, 700, 1050, 850, 400, 800, 500],
        lineStyle: {
          color: '#1fb9f6',
          width: 2
        },
        smooth: true,
      }
    ]
  });
})

</script>


<template>
  <div class="right-top">
    <div class="title">
      <p>景区排行</p>
      <img src="../../images/dataScreen-title.png" alt="">
    </div>

    <div class="charts" ref="charts"></div>
  </div>
</template>

<style scoped xml:lang="scss">

.right-top {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  margin: 10px 0px 20px 0px;

  .title {
    margin-left: 10px;

    p {
      color: white;
      font-size: 20px;
    }
  }
}
.charts {
  width: 100%;
  height: calc(100% - 45px);
}


</style>